package com.example.softwareconfigurationcoursedesign;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DBHelper {
    private static final String DB_CONN_RUL = "jdbc:mysql://localhost:3306/course_design?useSSL=false";
    private static final String DB_USER_NAME = "root";
    private static final String DB_PASSWORD = "123456";

    public DBHelper() {
    }

    public static Connection getConnection() {
        Connection connection = null;

        try {
            Class.forName("com.mysql.jdbc.Driver");
            connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/course_design?useSSL=false", "root", "123456");
        } catch (SQLException var2) {
            var2.printStackTrace();
        } catch (ClassNotFoundException var3) {
            var3.printStackTrace();
        }

        return connection;
    }

    public static void closeAll(Connection connection, PreparedStatement pstmt, ResultSet rs) {
        if (rs != null) {
            try {
                rs.close();
            } catch (Exception var6) {
                var6.printStackTrace();
            }
        }

        if (pstmt != null) {
            try {
                pstmt.close();
            } catch (Exception var5) {
                var5.printStackTrace();
            }
        }

        if (connection != null) {
            try {
                connection.close();
            } catch (Exception var4) {
                var4.printStackTrace();
            }
        }

    }
}
